#include "processbar.h"  
#include <unistd.h> 

typedef void (*callback_t)(int); //函数指针类型

//模拟一种安装或者下载
void downLoad(callback_t cb)
{
    int total =1000;
    int curr = 0;
    while(curr <=total)
    {
        usleep(50000);
        int rate=curr*100/total;  //更新进度

        cb(rate);  //通过回调，展示进度

        curr+=10;

    }
    printf("\n");
}



int main()
{
    printf("downLoad1:\n");
    downLoad(processbarCore); 
    printf("downLoad2:\n");
    downLoad(processbarCore);
    printf("downLoad3:\n");
    downLoad(processbarCore);
    printf("downLoad3:\n");
    downLoad(processbarCore);


    /*int total=1000;
    int curr=0;
    while(curr <= total)
    {
        processbarCore(curr*100/total);
        curr+=10;
        usleep(50000);
    }
    printf("\n");
    */ 

   /* int cnt =10;
    while(cnt>=0)
    {
        printf("%-2d\r",cnt);
        fflush(stdout);
        cnt--;
        sleep(1);
    }
    printf("\n");*/ 
    return 0;
}
